#!/bin/bash
export JAVA_HOME=${JAVA_HOME8}
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/

cd `dirname $0`
DEPLOY_DIR=`pwd`
app=sales-mall-service.jar

cd ${DEPLOY_DIR}
LOGS_DIR=${DEPLOY_DIR}/logs
if [ ! -d $LOGS_DIR ]; then
    mkdir $LOGS_DIR
fi

STDOUT_FILE=$LOGS_DIR/stdout.log

JAVA_MEM_OPTS=""
DUMP_PATH=$LOGS_DIR/java_heapdump.hprof
LOGGC_PATH=$LOGS_DIR/gc.log
BITS=`java -version 2>&1 | grep -i 64-bit`
if [ -n "$BITS" ]; then
    JAVA_MEM_OPTS=" -server -Xms6G -Xmx6G -XX:NewSize=2G -XX:MaxNewSize=2G -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$DUMP_PATH -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:$LOGGC_PATH -XX:+UseGCLogFileRotation
 -XX:NumberOfGCLogFiles=3 -XX:GCLogFileSize=1m"
else
    JAVA_MEM_OPTS=" -server -Xms2g -Xmx2g"
fi

nohup java $JAVA_MEM_OPTS -jar ${DEPLOY_DIR}/${app} --spring.profiles.active=pro > $STDOUT_FILE 2>&1  &